package com.postsuperman.proxypool.common;

import com.postsuperman.proxypool.common.enums.StatusEnum;
import com.postsuperman.proxypool.pojo.ResponseBean;

/**
 * @author ： Lwl postserupman
 * @Description TODO
 * @Date 2019/2/27 12:06
 * @Version 1.0
 */
public class Response {

    public static ResponseBean success() {
        ResponseBean responseBean = new ResponseBean();
        responseBean.setCode(StatusEnum.SUCCESS_CODE.getCode());
        responseBean.setMsg(StatusEnum.SUCCESS_CODE.getMsg());
        return responseBean;
    }

    public static ResponseBean success(Object obj) {
        ResponseBean responseBean = new ResponseBean();
        responseBean.setCode(StatusEnum.SUCCESS_CODE.getCode());
        responseBean.setMsg(StatusEnum.SUCCESS_CODE.getMsg());
        responseBean.setData(obj);
        return responseBean;
    }

    public static ResponseBean error(String msg) {
        ResponseBean responseBean = new ResponseBean();
        responseBean.setCode(StatusEnum.FAIL_CODE.getCode());
        responseBean.setMsg(msg);
        return responseBean;
    }

    public static ResponseBean error(StatusEnum statusEnum) {
        ResponseBean responseBean = new ResponseBean();
        responseBean.setCode(statusEnum.getCode());
        responseBean.setMsg(statusEnum.getMsg());
        return responseBean;
    }
}
